<?php
header('Content-Type: text/xml');
include_once('settings.php');
include_once('conn.php');
include_once('inc/lib.function.php');
?>
<?php
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<data>';
//query issue
_index_flash_xml_echo_catalog_block('issue');
//query collection
_index_flash_xml_echo_catalog_block('collection');
//query people
_index_flash_xml_echo_catalog_block('people');
//query shops
_index_flash_xml_echo_catalog_block('shops');
echo '</data>';
?>

<?php
function _index_flash_xml_echo_catalog_block($catalog)
{
	echo '<'.$catalog.'>';
  $data_list = _index_flash_xml_query_latest_catalog_article($catalog);
  foreach($data_list as $data)
  {
  		$link_url = sprintf('http://%s/%s?id=%d', $_SERVER['HTTP_HOST'], get_article_page_url_by_type($data['lb']), $data['id']);
  		//$link_url = urlencode($link_url);
  		echo '<item>';
  		echo '<title>'.html_safe($data['title']).'</title>';
  		echo '<img>upfiles/'.html_safe($data['images1']).'</img>';
  		echo '<url>'.html_safe($link_url).'</url>';
  		echo '</item>';
  }
	echo '</'.$catalog.'>';
}
function _index_flash_xml_query_latest_catalog_article($catalog,$size = 2)
{
	//$data_list = array();
	$data_list = get_article_lock_list('Feature',$catalog);
	$lock_size = count($data_list);
	
	if($lock_size < $size)
	{
	$size = $size - $lock_size;
	$query = sprintf("SELECT `id`,`title`,`images1`,`lb` FROM `news` WHERE `isok`='1' AND `BigClassName`='Feature' AND `BigClassName2`='%s' ORDER BY `id` DESC limit 0,%d",$catalog,$size);
	$result=mysql_query($query);
	if($result == false)
		exit(sprintf("%s%s%s",mysql_error(),__FILE__,__LINE__));
	while(($row = mysql_fetch_assoc($result)))
	{
			$data_list[] = $row;
	}
	}
	return $data_list;
}
?>